package edu.pku.sei.modeler.model.notation.shape.extradata;

import org.eclipse.draw2d.Shape;
import org.w3c.dom.Element;

import edu.pku.sei.modeler.model.core.MetaModelElement;
import edu.pku.sei.modeler.model.notation.core.NotationPackage;
import edu.pku.sei.modeler.model.xml.XMLUtility;

public class CornerRectangleData  extends ExtraData{
	static public final int TOPLEFT = 0;
	static public final int TOPRIGHT = 1;
	static public final int BOTTOMLET = 2;
	static public final int BOTTOMRIGHT = 3;
	
	private int direction;
	private int width;
	
	public CornerRectangleData(MetaModelElement host){
		super(host);
		setDirection(TOPRIGHT);
		setWidth(5);
	}

	public void setDirection(int direction) {
		this.direction = direction;
	}

	public int getDirection() {
		return direction;
	}

	public void setWidth(int width) {
		this.width = width;
	}

	public int getWidth() {
		return width;
	}

	@Override
	public void refreshFigure(Shape shape) {
		
	}
	//add by fengchao
	public void serialize(Element root) {
		super.serialize(root);
		XMLUtility.xmlInstance.serializeAttribute(root, NotationPackage.CORNERRECTANGLEDATA_DIRECTION, direction);
		XMLUtility.xmlInstance.serializeAttribute(root, NotationPackage.CORNERRECTANGLEDATA_WIDTH, width);
	}
	public void deSerialize(Element root) {
		super.deSerialize(root);
		direction = XMLUtility.xmlInstance.deSerializeInt(root, NotationPackage.CORNERRECTANGLEDATA_DIRECTION);
		width = XMLUtility.xmlInstance.deSerializeInt(root, NotationPackage.CORNERRECTANGLEDATA_WIDTH);
		
	}
	//end add
	
}